package com.myapp;

import android.app.Application;

import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.beefe.picker.PickerViewPackage;
import com.facebook.react.shell.MainReactPackage;
import com.gizwits.gizwifisdk.api.GizWifiSDK;
import com.horcrux.svg.SvgPackage;
import com.myapp.Data.GizManger;
import com.myapp.RN.CustomOpenNativePackage;
import com.oblador.vectoricons.VectorIconsPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

public class MainApplication extends Application implements ReactApplication {
  public static final String APP_ID = "f24a7fdb76dc43af897bfc7f8079f514";
  public static final String APP_S = "4f5441985a3d4ac1802dd7ef92811b20";

  public static final String PRODUCT_KEY = "9bf8701a49eb438992ad23fdfca3f2a7";
  public static final String PRODUCT_S = "de6d7e077f1f462eb64e5f8941491db6";
  private static final CustomOpenNativePackage customOpenNativePackage = new CustomOpenNativePackage();
  private static final PickerViewPackage pickerViewPackage = new PickerViewPackage();

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    public boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
//      @SuppressWarnings("UnnecessaryLocalVariable")
      List<ReactPackage> packages = new PackageList(this).getPackages();
//      // Packages that cannot be autolinked yet can be added manually here, for example:
//      // packages.add(new MyReactNativePackage());
      packages.add(customOpenNativePackage);
      packages.add(pickerViewPackage);

      return packages;
//      return Arrays.<ReactPackage>asList(
//              new MainReactPackage(),
//            new PickerViewPackage(),
//              customOpenNativePackage
//      );
    }



    @Override
    protected String getJSMainModuleName() {
      return "index";
    }
  };

  public static CustomOpenNativePackage getOpenNativePackage(){
      return customOpenNativePackage;
  }
  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);

    ConcurrentHashMap<String, String> appInfo = new ConcurrentHashMap<>();
    appInfo.put("appId",APP_ID);
    appInfo.put("appSecret",APP_S);

    List<ConcurrentHashMap<String, String>> productInfo = new LinkedList<>();
    ConcurrentHashMap<String,String> proInfo = new ConcurrentHashMap<>();
    proInfo.put("productKey",PRODUCT_KEY);
    proInfo.put("productSecret",PRODUCT_S);
    productInfo.add(proInfo);
    GizWifiSDK.sharedInstance().startWithAppInfo(getApplicationContext(),appInfo,productInfo,null,true);


  }
}
